#pragma once
#include "Helper.h"
#include <stdio.h>
#include "ScannerV0.h"

class TokenPrinter
{

public:

    static void printToken(FILE* stream, Token* t, ScannerV0* scanner)
    {
        switch (t->getType()) {
            case TOK_PLUS:
                fprintf(stream, "Token Plus                    Line: %5d Column: %5d Lexem: +\n", t->getRow(), t->getCol());
                break;
            case TOK_MINUS:
                fprintf(stream, "Token Minus                   Line: %5d Column: %5d Lexem: -\n", t->getRow(), t->getCol());
                break;
            case TOK_SLASH:
                fprintf(stream, "Token Slash                   Line: %5d Column: %5d Lexem: /\n", t->getRow(), t->getCol());
                break;
            case TOK_STAR:
                fprintf(stream, "Token Star                    Line: %5d Column: %5d Lexem: *\n", t->getRow(), t->getCol());
                break;
            case TOK_ANGLE_BR_OPEN:
                fprintf(stream, "Token Angle Brackets Open     Line: %5d Column: %5d Lexem: <\n", t->getRow(), t->getCol());
                break;
            case TOK_ANGLE_BR_CLOSE:
                fprintf(stream, "Token Angle Brackets Close    Line: %5d Column: %5d Lexem: >\n", t->getRow(), t->getCol());
                break;
            case TOK_ASSIGN:
                fprintf(stream, "Token Assign                  Line: %5d Column: %5d Lexem: =\n", t->getRow(), t->getCol());
                break;
            case TOK_EXCL:
                fprintf(stream, "Token Exclamation             Line: %5d Column: %5d Lexem: !\n", t->getRow(), t->getCol());
                break;
            case TOK_AMPERSAND:
                fprintf(stream, "Token Ampersand               Line: %5d Column: %5d Lexem: &\n", t->getRow(), t->getCol());
                break;
            case TOK_SEMICOLON:
                fprintf(stream, "Token Semicolon               Line: %5d Column: %5d Lexem: ;\n", t->getRow(), t->getCol());
                break;
            case TOK_BR_OPEN:
                fprintf(stream, "Token Brackets Open           Line: %5d Column: %5d Lexem: (\n", t->getRow(), t->getCol());
                break;
            case TOK_BR_CLOSE:
                fprintf(stream, "Token Brackets Close          Line: %5d Column: %5d Lexem: )\n", t->getRow(), t->getCol());
                break;
            case TOK_CURLY_BR_OPEN:
                fprintf(stream, "Token Curly Brackets Open     Line: %5d Column: %5d Lexem: {\n", t->getRow(), t->getCol());
                break;
            case TOK_CURLY_BR_CLOSE:
                fprintf(stream, "Token Curly Brackets Close    Line: %5d Column: %5d Lexem: }\n", t->getRow(), t->getCol());
                break;
            case TOK_SQ_BR_OPEN:
                fprintf(stream, "Token Square Brackets Open    Line: %5d Column: %5d Lexem: [\n", t->getRow(), t->getCol());
                break;
            case TOK_SQ_BR_CLOSE:
                fprintf(stream, "Token Square Brackets Close   Line: %5d Column: %5d Lexem: ]\n", t->getRow(), t->getCol());
                break;
    
            case TOK_SPECIAL:
                fprintf(stream, "Token Special                 Line: %5d Column: %5d Lexem: <!>\n", t->getRow(), t->getCol());
                break;
            case TOK_INTEGER:
                fprintf(stream, "Token Integer                 Line: %5d Column: %5d Value: %d\n", t->getRow(), t->getCol(), t->getInt());
                break;
            case TOK_IDENTIFIER: {
                if(scanner == NULL)
                    fprintf(stream, "Token Identifier              Line: %5d Column: %5d\n", t->getRow(), t->getCol());
                else
                    fprintf(stream, "Token Identifier              Line: %5d Column: %5d Lexem: %s\n", t->getRow(), t->getCol(), scanner->lookup(t->getKey()).lexem);
                break; }
            case TOK_COMMENT_OPEN:
                fprintf(stream, "Token Comment Open            Line: %5d Column: %5d Lexem: /*\n", t->getRow(), t->getCol());
                break;
            case TOK_COMMENT_CLOSE:
                fprintf(stream, "Token Comment Close           Line: %5d Column: %5d Lexem: */\n", t->getRow(), t->getCol(), t->getChar());
                break;
            //Added in Task 2
            case TOK_COLON:
                fprintf(stream, "Token Colon                   Line: %5d Column: %5d Lexem: :\n", t->getRow(), t->getCol());
                break;
            case TOK_PRINT:
                fprintf(stream, "Token Print                   Line: %5d Column: %5d Lexem: PRINT\n", t->getRow(), t->getCol());
                break;
            case TOK_READ:
                fprintf(stream, "Token Read                    Line: %5d Column: %5d Lexem: READ\n", t->getRow(), t->getCol());
                break;
            case TOK_IF:
                fprintf(stream, "Token If                      Line: %5d Column: %5d Lexem: IF\n", t->getRow(), t->getCol());
                break;
            case TOK_ELSE:
                fprintf(stream, "Token Else                    Line: %5d Column: %5d Lexem: ELSE\n", t->getRow(), t->getCol());
                break;
            case TOK_WHILE:
                fprintf(stream, "Token While                   Line: %5d Column: %5d Lexem: WHILE\n", t->getRow(), t->getCol());
                break;
            case TOK_INT:
                fprintf(stream, "Token Int                     Line: %5d Column: %5d Lexem: INT\n", t->getRow(), t->getCol());
                break;
    
            default: //UNDEF
                break;
        }
    }
};
